import subprocess, os

#此脚本作用是快速生成图片的.qrc文件，把.qrc文件用pyRcc转换成.py文件后导入MP3Player.py文件中，保证打包成.exe后图片不丢失
images = os.listdir("D:\\python_project\\MP3Player-master\\resource\\images")
# qss = os.listdir('./qss')
f = open('images.qrc', 'w+')
f.write(u'<!DOCTYPE RCC>\n<RCC version="1.0">\n<qresource>\n')

for item in images:
    f.write(u'<file alias="resource/images/'+ item +'">resource/images/'+ item +'</file>\n')

# for item in qss:
#     f.write(u'<file alias="qss/'+ item +'">qss/'+ item +'</file>\n')

f.write(u'</qresource>\n</RCC>')
f.close()

pipe = subprocess.Popen(r'pyrcc5 -o images.py images.qrc', stdout = subprocess.PIPE, stdin = subprocess.PIPE, stderr = subprocess.PIPE, creationflags=0x08)
print("success")